const fs = require("fs");
//
const Koa = require("koa");
// 注意require('koa-router')返回的是函数:
const router = require("koa-router")();
//
const bodyParser = require("koa-bodyparser");
//
const app = new Koa();
//
app.use(bodyParser());
//
const controller = require("./controller");
//
/* //console.log(__dirname);
let files = fs.readdirSync(`${__dirname}/controllers`);
//console.log(files);
let js_files = files.filter(f=>{
    return f.endsWith(".js")
})
//
//console.log(js_files);
for (const f of js_files) {
    const mapping = require(`${__dirname}/controllers/${f}`);
    console.log(mapping);
} */
//
app.use(controller.addControllers());
//
app.listen("3000", () => {
    console.log(`服务器已启动，http://localhost:3000`)
})